/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.img;

import java.io.IOException;
import java.util.Hashtable;
import com.sun.lwuit.Image;


/**
 *
 * @author ademar.victorino
 */
public class ImageStore {

    private static ImageStore instance = new ImageStore();
    private Hashtable images = new Hashtable();

    private ImageStore() {

    }

    public static ImageStore getInstance() {
        return instance;
    }

    public Image getImage(String name){
        Image im = (Image)images.get(name);
        if(im == null){
            if(name.indexOf(".png") == -1 ){
                name += ".png";
            }
            try {
                im = Image.createImage("/view/img/" + name);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return im;
    }

}
